-
Notifications
You must be signed in to change notification settings - Fork 7.4k
build: Allow custom sysroot in native_sim builds #90357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
build: Allow custom sysroot in native_sim builds #90357
Conversation
@yperess would you be so kind as to clarify a bit more what you would like to do? |
@aescolar happy to and thank you for being so responsive on this issue. This is what I'm trying to get passing https://pigweed-review.git.corp.google.com/c/pigweed/pigweed/+/293592. This chage calls twister for the Pigweed project and tests all the Zephyr backends. The important details for this call are: The environment variables are set here def _env_with_zephyr_vars(ctx: PresubmitContext) -> dict:
"""Returns the environment variables with ... set for Zephyr."""
env = os.environ.copy()
# Set some variables here.
env['ZEPHYR_BASE'] = str(ctx.package_root / 'zephyr')
env['ZEPHYR_MODULES'] = str(ctx.root)
env['ZEPHYR_TOOLCHAIN_VARIANT'] = 'llvm'
return env Then the call: def zephyr_build(ctx: PresubmitContext) -> None:
"""Run Zephyr compatible tests"""
# Install the Zephyr package
build.install_package(ctx, 'zephyr')
# Configure the environment
env = _env_with_zephyr_vars(ctx)
sysroot_dir = (
ctx.pw_root
/ 'environment'
/ 'cipd'
/ 'packages'
/ 'pigweed'
/ 'clang_sysroot'
)
platform_filters = (
['-P', 'native_sim']
if platform.system() in ['Windows', 'Darwin']
else []
)
# Run twister
call(
'pw',
'twister-runner',
'-vvv',
'--ninja',
'--integration',
'--clobber-output',
'--inline-logs',
'--verbose',
'--coverage',
'--coverage-basedir',
str(ctx.pw_root),
*platform_filters,
f'-x=TOOLCHAIN_C_FLAGS=--sysroot={sysroot_dir}',
f'-x=TOOLCHAIN_LD_FLAGS=--sysroot={sysroot_dir}',
'--testsuite-root',
str(ctx.pw_root),
env=env,
) Pigweed sets up a hermetic environment so things don't get installed in the "normal" places. Where ever you download pigweed into is your
So you can see everything is under the Some links for reference: |
@yperess thanks. Now I understand. I'm guessing that clang installation does not have as default sysroot that Maybe we should fix setting SYSROOT_DIR for clang (and maybe as a bonus also for the host gcc) and when it is set have it passed to the native sim runner build(?) |
@aescolar I think I need more context, I know my way around the Zephyr build but I'm not an expert by any means. Let's chat on discord to avoid polluting this PR comments. |
c17dd88
to
09014f5
Compare
767bed2
to
12d2e2d
Compare
When running naive sim builds using clang, respect user passed SYSROOT_DIR values. Additionally, allow overriding the archive tool when calling Make for the native simulator. Add the sysroot (if available) to the native_simulator target and TOOLCHAIN_C_FLAGS and TOOLCHAIN_LD_FLAGS. Additionally pass CMAKE_AR to NSI_AR. Signed-off-by: Yuval Peress <[email protected]>
12d2e2d
to
e5b91f2
Compare
@aescolar this is much better, thank you for helping clean this PR up. It passed my CI downstream using https://pigweed-review.git.corp.google.com/c/pigweed/pigweed/+/293592 (Check https://ci.chromium.org/ui/p/pigweed/builders/pigweed.try/pigweed-linux-zephyr/b8713553788173861361/overview). Once this PR merges I will clean up my downstream change and we'll be good to go. |
|
Looking good to me on a very quick look. Will re-review a bit later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+2
Thanks @yperess it looks good to me.
When running naive sim builds, any custom cflags and toolchains we've set are lost. Specifically for us this included a custom directory for the sysroot and archive tool.
Add the sysroot (if available) to both NSI_BUILD_C_OPTIONS and a new NSI_EXTRA_LINK_OPTIONS. Additionally pass CMAKE_AR to NSI_AR.